#include<bits/stdc++.h>
using namespace std;
bool arr[14];
int solve() {
  int x;cin>>x;
  fill(arr,arr+14,false);
  for(int i=9;i!=0 && x!=0;--i) {
    if(x-i>=0) {
      x-=i;arr[i]=true;
    }
  }
  bool yes = false;
  for(int i=0;i<10;++i) {
    if(x!=0)break;
    if(arr[i]) {
      cout<<i;
      yes = true;
    }
  }
  if(!yes) cout<<"-1\n";
  else cout<<"\n";
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  int tc;cin>>tc;
  for(int t = 1; t <= tc; t++) {
    // cout << "Case #" << t << ": \n"
    solve();
  }
  return 0;
}
